<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: zhukang
  Date: 2021-06-26
  Time: 10:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>电子文档详情</title>
</head>
<body>
    <!-- springmvc的form表单标签：方便实现表单开发，数据快速回显 -->
    <h2 align="center">电子文档详情</h2>
    <!--  form表单标签必须写在 form:form中才可以 -->
    <form:form action="/edocInfo" method="post" modelAttribute="edocEntry">
        <!-- 判断是添加还是修改 -->
        <c:if test="${!empty edocEntry.id}" var="flag">
            <form:hidden path="id"/>
            <input type="hidden" name="_method" value="put"/>
        </c:if>
        <table  border="1px" width="50%" align="center" cellspacing="0" style="background-color: antiquewhite">
            <tr>
                <td>文档分类：</td>
                <td>
                    <!-- items指定遍历的集合，itemLabel对应展示的文字，itemValue对应提交的值，相当于以前的<option value="itemValue">itemLabel</option> -->
                    <form:select path="edocCategory.id" items="${edocCategories}" itemLabel="name" itemValue="id"/>
                </td>
            </tr>
            <tr>
                <td>书名：</td>
                <td>
                    <form:input path="title"/>
                </td>
            </tr>
            <tr>
            <td>摘要：</td>
            <td><form:input path="summary"/></td>
            </tr>
            <tr>
                <td>作者：</td>
                <td><form:input path="uploadUser"/></td>
            </tr>

            <tr>
                <td>上传日期：</td>
                <td><form:input path="createDate" />yyyy-MM-dd</td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <c:if test="${flag}">
                        <input type="submit" value="修改"/>
                    </c:if>
                    <c:if test="${!flag}">
                        <input type="submit" value="添加"/>
                    </c:if>
                    <input type="button" value="返回"/>
                </td>
            </tr>
        </table>

    </form:form>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
<script>
    $(function () {
        $("input[type=button]").click(function () {
            history.back();
        })
    })
</script>
</html>
